﻿@model SchoolCommunicationSystem.Models.ListParentsAddViewModel
@{
    ViewBag.Title = "Tài khoản phụ huynh";
}
@Scripts.Render("~/bundles/tablesorter")
@Scripts.Render("~/bundles/tablesorterpaging")
<script type="text/javascript">
    $(function () {

        $("tablesorter")
            .tablesorter({
                widthFixed: true, widgets: ['zebra'], headers: { 6: { sorter: false } }
            })
            .tablesorterPager({ container: $("#pagersorter") });
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {

        $("#ParentsAccount").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-edit").dialog({
                title: 'Tài khoản phụ huynh',
                autoOpen: false,
                resizable: false,
                height: 550,
                width: 420,
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-edit").dialog('open');
            return false;
        });

        $(".editDialog").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-edit").dialog({
                title: 'Sửa thông tin tài khoản phụ huynh',
                autoOpen: false,
                resizable: false,
                height: 550,
                width: 420,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-edit").dialog('open');
            return false;
        });

        $(".confirmDialog").live("click", function (e) {

            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');

            $("#dialog-confirm").dialog({
                autoOpen: false,
                resizable: false,
                height: 170,
                width: 350,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
                        window.location = url;

                    },
                    "Cancel": function () {
                        $(this).dialog("close");

                    }
                }
            });
            $("#dialog-confirm").dialog('open');
            return false;
        });

        $(".viewDialog").live("click", function (e) {
            // e.preventDefault(); use this or return false
            var url = $(this).attr('href');
            $("#dialog-view").dialog({
                title: 'View Parent',
                autoOpen: false,
                resizable: false,
                height: 250,
                width: 400,
                show: { effect: 'drop', direction: "up" },
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);

                },
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");

                    }
                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

            $("#dialog-view").dialog('open');
            return false;
        });

        $("#btncancel").live("click", function (e) {
            // location.reload(true);
            $("#dialog-edit").dialog('close');

        });
    });
</script>
@Scripts.Render("~/bundles/tablesorter")
@Scripts.Render("~/bundles/tablesorterpaging")
<script type="text/javascript">
    $(function () {

        $("table")
            .tablesorter({
                widthFixed: true, widgets: ['zebra']
            })
            .tablesorterPager({ container: $("#pagersorter") });
    });
</script>

<div id="page-heading">
    <h1>Quản lý tài khoản</h1>
</div>
<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Quản lý tài khoản phụ huynh</h4>
                </div>
                <div class="panel-body">
                    <div class="module_contentwithsearch">
                        @using (Html.BeginForm("ParentsAccount", "AccountManagement", FormMethod.Post, new { @class = "form-horizontal" }))
                        { 
                            <div class="form-group" style="margin-bottom: 0px;">
                                @Html.Label("Tên Đăng Nhập:", new { @class = "col-sm-2", @style = "width: 12%;" })
                                <div class="col-sm-2">
                                    @Html.TextBox("searchString")
                                </div>
                                <div class="col-sm-3">
                                    <button class="btn-primary btn searchbtn" type="submit" style="padding: 4px 15px; font-size: 13px; font-weight: 500;">Tìm kiếm</button>
                                </div>
                            </div>
              
                        }
                    </div>
                    <div class="module_contentresult">
                        <br />
                        <table class="tablesorter">
                            <thead>
                                <tr>
                                    <th style="width:17%;">Họ tên</th>
                                    <th style="width:17%;">Tên đăng nhập</th>
                                    <th style="width:10%;">Giới tính</th>
                                    <th style="width:15%;">Số điện thoại di động</th>
                                    <th style="width:26%;">Email</th>
                                    <th style="width:10%;">Trạng thái</th>
                                                <th style="text-align: center;width:5%">Sửa</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var item in Model.ParentsList)
                                {
                                    <tr>
                                        <td>@item.Parents.FirstOrDefault().parentName</td>
                                        <td>@item.userName</td>
                                        @if (item.Parents.FirstOrDefault().gender == "M")
                                        {
                                            <td>Nam</td>
                                        }
                                        else
                                        {
                                            <td>Nữ</td>
                                        }
                                        <td>@item.Parents.FirstOrDefault().mobile</td>
                                        <td>@item.email</td>
                                        @if (item.isLockedOut == false)
                                        {
                                            <td>Hoạt động</td>
                                        }
                                        else
                                        {
                                            <td><b>Ngừng hoạt động</b></td>
                                        }
                                                                                  <td style="text-align: center; align-content: center;align-items:center;">
                                            <a class="editDialog" href="@Url.Action("UpdateParentAccount", "AccountManagement", new { id = item.userID })"><i class="fa fa-pencil"></i></a>
                                        </td>
                                    </tr>
                                }
                            </tbody>
                        </table>
                        <div id="pagersorter" class="pagersorter">
                            <form class="form-horizontal">
                                <img src="../../Content/images/first.png" class="first" />
                                <img src="../../Content/images/prev.png" class="prev" />
                                <input type="text" class="pagedisplay" />
                                <img src="../../Content/images/next.png" class="next" />
                                <img src="../../Content/images/last.png" class="last" />
                                <select class="pagesize">
                                    <option selected="selected" value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                    <option value="40">40</option>
                                </select>
                            </form>
                        </div>

                        <div style="color: Green; font-weight: bold">
                            @TempData["msg"]
                        </div>
                        <div id="dialog-confirm" style="display: none">
                            <p>
                                <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
                                Bạn có muốn xóa ko ?
                            </p>
                        </div>
                        <div id="dialog-edit" style="display: none">
                        </div>
                        <div id="dialog-view" style="display: none">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
